Repository navigation
feat(extraction): add Tcl language support - #3568
Open
zhiping-biubiu wants to merge 1 commit into
Open
zhiping-biubiu wants to merge 1 commit into
zhiping-biubiu wants to merge 1 commit into
Conversation
Tcl (.tcl, .tm): `proc` definitions, procs in `namespace eval` qualified by their full namespace path (nested levels composed, however each level is spelled) as methods, `set` assignments as variables, `source` / `package require` imports, and call edges between procs across files — including names written absolutely (`::utils::log`). The resolver's root-qualified-name gate is Tcl-only: `hasAnyPossibleMatch` keeps `> 0`, and the leading `::` is stripped in the `existenceName` branch that already answers C/C++ (colbymchenry#2445), so no other language changes. Grammar provenance, build recipe and the grammar's measured limits live in docs/grammars/tree-sitter-tcl.md, with the scanner patch (a `;` glued to a word is a command terminator) as docs/grammars/tree-sitter-tcl.patch — upstream issue colbymchenry#41 / PR colbymchenry#42 is closed unmerged, so the patch ships here. Changelog (`[Unreleased]`), README and the site language table updated; README lists Tcl as partial support, with the gaps documented. EXTRACTION_VERSION 31. Tests: extraction 785 (16 for Tcl), resolution 255 (5 for Tcl), and the C/C++ global-scope, Ruby and pr19 suites.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2249, rebased on today's main. The four things that PR was closed for:
::pre-filter is not widened.hasAnyPossibleMatchkeeps> 0; aroot-qualified name has its leading
::stripped fortclin the existing C/C++branch (
existenceName), exactly as fix(cpp): a call written from the global scope links the declaration of exactly that name #2445 does for C/C++, so no other languagechanges. (Ruby's
::Fooand everything else behave as before.)__tests__/resolution.test.ts, "Tcl resolution":::utils::loglinks across files to the namespace that declares it and not to asame-named
login another namespace; a namespace spelled without the rootseparator; nested namespaces;
proc ::abs::f; a builtin / dynamic command word /name nothing declares (no edge);
source(file edge, no call). Extraction caseswent 8 → 16.
[Unreleased]→ New Features; README "20+ Languages" andthe Supported Languages table; the site's language table too.
docs/grammars/tree-sitter-tcl.md(source repo, commit,MIT, wasm sha256, rebuild command, measured limits) and the scanner patch as a
.patchfile. Upstream feat: Add Pascal/Delphi support (Tree-sitter & DFM extraction) #41 / CodeGraph v0.6.2: FOREIGN KEY constraint failed #42 is closed unmerged, so the patch has to shipwith us.
What the extractor does
proc→ functions; procs insidenamespace eval→ methods qualified by their fullabsolute path.
namespace eval utils { proc ping }, nested::a/::bandproc ::a::b::fall produce one shape:pingat::utils::ping.set name valueat file scope → variables (a bareset nameread is not one).source x.tcl→ file import edge;package require Tk→ package import, no file orcall edge. Both work inside a proc body as well.
puts,return,lsort, …, and the TclOO class commands) areclaimed, so no phantom
callstarget is minted; dynamic command words ($cmd, aliteral,
[$obj method]) are skipped.Measured on Tcl's own library
269
.tclfiles of Tcl 8.5 (lib/tcl8.5,lib/tk8.5,lib/teapot): 166 parse withan ERROR node (62%) and 14 yield no symbols. The cause is the upstream grammar: it
attaches
array_indexto a bare word only, never to a variable substitution, so$arr(key)— Tk's whole theme system — is an error. Extraction still finds 2,409functions, 142 namespaced methods, 1,752 variables and 219 imports. The gap, its
size and what it costs are in
docs/grammars/tree-sitter-tcl.md; README sayspartial support rather than full.
Tests
npx vitest run __tests__/extraction.test.ts— 785 passednpx vitest run __tests__/resolution.test.ts— 255 passedcpp-global-scope-names/ruby-namespaced-receiver/pr19-improvements— greennpx tsc --noEmit— clean.tclfile, and the graph dump excludesEXTRACTION_VERSION, so GRAPH cannot move).EXTRACTION_VERSIONis 31: a project indexed earlier picks Tcl up oncodegraph index.